package com.yanqu.road.server.cmd.activity.sonhai;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SonHaiProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.sonhai.SonHaiActivityMgr;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = SonHaiProto.SonHaiSelectBuffReqMsg.class, respMsg = SonHaiProto.SonHaiSelectBuffRespMsg.class)
@Cmd(code = Protocol.S_SON_HAI_SELECT_BUFF,desc = "山海伏兽-选择BUFF")
public class SonHaiSelectBuffCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        SonHaiProto.SonHaiSelectBuffReqMsg reqMsg = SonHaiProto.SonHaiSelectBuffReqMsg.parseFrom(packet.getBytes());
        try {
            //选择BUFF
            SonHaiActivityMgr.selectBuff(player, reqMsg);
        } catch (BusinessException e) {
            SonHaiProto.SonHaiSelectBuffRespMsg.Builder respMsg = SonHaiProto.SonHaiSelectBuffRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
            player.sendPacket(Protocol.U_SON_HAI_SELECT_BUFF, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
